#define __LIBRARY__

#include <stdlib.h>
#include <unistd.h>
#include <linux/sched.h>
#include <errno.h>




_syscall1(int,thread_init,pthread_attr_t *,attr);

_syscall3(int,thread_fork,const pthread_attr_t *,attr,void *,start_routine,void *,arg);

_syscall2(int,thread_join,pthread_t,thread,void **,value_ptr);

_syscall1(int,thread_exit,void *,value_ptr);


int pthread_create(pthread_t *thread,const pthread_attr_t* attr,void* (*start_routine)(void *),void* arg)
{
	pthread_t t_id;
	t_id = thread_fork(attr,start_routine,arg);
	if(t_id == -1)
		return errno;

	if(t_id > 0)
	{
		(*thread) = t_id;
		return 0;
	}

	return -1;
}

int pthread_join(pthread_t thread,void** value_ptr)
{
		
	thread_join(thread,value_ptr);

	return 0;
}

void pthread_exit(void* value_ptr)
{
	thread_exit(value_ptr);
}






















